import request from '@/utils/request'

// 创建分解动作（归属视频集）
export function createAction(data) {
  // 预期 data 包含 courseId, episodeId, actionName, actionDesc, sort
  return request({
    url: '/course/action',
    method: 'post',
    data
  })
}

export function listAction(query) {
  return request({
    url: '/course/action/list',
    method: 'get',
    params: query
  })
}

export function updateAction(data) {
  return request({
    url: '/course/action',
    method: 'put',
    data: data
  })
}

// 根据视频集ID查询动作列表
export function listActionByEpisode(episodeId) {
  return request({
    url: '/course/action/listByEpisode/' + episodeId,
    method: 'get'
  })
}

// 删除动作
export function delAction(actionId) {
  // 支持单个ID或ID数组，数组转换为逗号分隔的字符串
  const ids = Array.isArray(actionId) ? actionId.join(',') : actionId
  return request({
    url: '/course/action/' + ids,
    method: 'delete'
  })
}

// 获取动作详细信息
export function getAction(actionId) {
  return request({
    url: '/course/action/' + actionId,
    method: 'get'
  })
}




